﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Practices.Prism;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;

using Warehouse.Silverlight.Core.Infrastructure;
using Warehouse.Silverlight.Modules.Main.Models;
using Warehouse.Silverlight.Modules.Main.ViewModels;

namespace Warehouse.Silverlight.Modules.Main.Views
{
    [Export("TestList")]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public partial class TestListView : UserControl, INavigationAware
    {
        private readonly IRegionManager _regionManager;

        [ImportingConstructor]
        public TestListView(IRegionManager regionManager)
        {
            InitializeComponent();

            _regionManager = regionManager;
            _regionManager.RegisterViewWithRegion(MainModuleRegionNames.EditorRegion, typeof(TestEditorView));
        }

        [Import]
        public TestListViewModel ViewModel
        {
            set { this.DataContext = value; }
        }

        #region INavigationAware Members

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            navigationContext.NavigationService.Region.Remove(this);
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            
        }

        #endregion

    }
}
